<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Models\GoodsCategory as GoodsCategoryModel;

class GoodsCategory extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'parent_id' => $this->pid,
            'name' => $this->name,
            'is_show_text' => GoodsCategoryModel::IS_ADMIN_MAP[$this->is_show],
            'is_show' => $this->is_show,
            'status' => $this->status,
            'status_text' => GoodsCategoryModel::STATUS_MAP[$this->status],
            'is_admin' => $this->is_admin,
            'is_admin_text' => GoodsCategoryModel::IS_ADMIN_MAP[$this->is_admin],
            'sequence' => $this->sequence,
        ];
    }
}
